#include <QStyleFactory>
#include <QStyle>
#include <QToolButton>
#include <QPainter>

#include <QDebug>

#include "harustyle.h"

HaruStyle *HaruStyle::inst = nullptr;

HaruStyle::HaruStyle() :
    m_style(QStyleFactory::create("fusion"))
{
}

HaruStyle *HaruStyle::instance()
{
    return inst;
}

void HaruStyle::initial()
{
    //Check instance pointer.
    if(!inst)
    {
        //Create the instance pointer.
        inst = new HaruStyle();
    }
}

HaruStyle::~HaruStyle()
{
}

void HaruStyle::drawComplexControl(QStyle::ComplexControl cc,
                                   const QStyleOptionComplex *opt,
                                   QPainter *p, const QWidget *widget) const
{
    m_style->drawComplexControl(cc, opt, p, widget);
}

void HaruStyle::drawControl(QStyle::ControlElement element,
                            const QStyleOption *opt, QPainter *p,
                            const QWidget *widget) const
{
    m_style->drawControl(element, opt, p, widget);
}

void HaruStyle::drawPrimitive(QStyle::PrimitiveElement pe,
                              const QStyleOption *opt, QPainter *p,
                              const QWidget *widget) const
{
    m_style->drawPrimitive(pe, opt, p, widget);
}

QPixmap HaruStyle::generatedIconPixmap(QIcon::Mode iconMode,
                                       const QPixmap &pixmap,
                                       const QStyleOption *opt) const
{
    return m_style->generatedIconPixmap(iconMode, pixmap, opt);
}

QStyle::SubControl HaruStyle::hitTestComplexControl(
        QStyle::ComplexControl cc, const QStyleOptionComplex *opt,
        const QPoint &pt, const QWidget *widget) const
{
    return m_style->hitTestComplexControl(cc, opt, pt, widget);
}

int HaruStyle::layoutSpacing(QSizePolicy::ControlType control1,
                             QSizePolicy::ControlType control2,
                             Qt::Orientation orientation,
                             const QStyleOption *option,
                             const QWidget *widget) const
{
    return m_style->layoutSpacing(control1, control2, orientation, option,
                                  widget);
}

int HaruStyle::pixelMetric(QStyle::PixelMetric m, const QStyleOption *opt,
                           const QWidget *widget) const
{
    return m_style->pixelMetric(m, opt, widget);
}

void HaruStyle::polish(QPalette &pal)
{
    m_style->polish(pal);
}

void HaruStyle::polish(QApplication *app)
{
    m_style->polish(app);
}

void HaruStyle::polish(QWidget *widget)
{
    m_style->polish(widget);
}

QSize HaruStyle::sizeFromContents(QStyle::ContentsType ct,
                                  const QStyleOption *opt, const QSize &csz,
                                  const QWidget *widget) const
{
    return m_style->sizeFromContents(ct, opt, csz, widget);
}

QPixmap HaruStyle::standardPixmap(QStyle::StandardPixmap sp,
                                  const QStyleOption *option,
                                  const QWidget *widget) const
{
    return m_style->standardPixmap(sp, option, widget);
}

int HaruStyle::styleHint(QStyle::StyleHint sh, const QStyleOption *opt,
                         const QWidget *widget, QStyleHintReturn *hret) const
{
    return m_style->styleHint(sh, opt, widget, hret);
}

QRect HaruStyle::subControlRect(QStyle::ComplexControl cc,
                                const QStyleOptionComplex *opt,
                                QStyle::SubControl sc,
                                const QWidget *widget) const
{
    return m_style->subControlRect(cc, opt, sc, widget);
}

QRect HaruStyle::subElementRect(QStyle::SubElement sr, const QStyleOption *opt,
                                const QWidget *widget) const
{
    return m_style->subElementRect(sr, opt, widget);
}

void HaruStyle::unpolish(QWidget *widget)
{
    m_style->unpolish(widget);
}

void HaruStyle::unpolish(QApplication *application)
{
    m_style->unpolish(application);
}

